# encoding: utf-8
"""
Notify Modules
=======

Modules enable logical resource separation.

You may control enabled modules by modifying ``ENABLED_MODULES`` config
variable.
"""
from flask import render_template
from flask_socketio import SocketIO
from .notifier import NotifierNamespace
sio = None


def init_app(app, **kwargs):
    """
    Init notify module.
    """

    @app.route('/')
    def index():
        return render_template('index.html')

    # Set this variable to "threading", "eventlet" or "gevent" to test the
    # different async modes, or leave it set to None for the application to choose
    # the best option based on installed packages.
    async_mode = None
    global sio
    sio = SocketIO(app, async_mode=async_mode)
    sio.init_app(app)
    app.config['socketio_app'] = sio
    sio.on_namespace(NotifierNamespace())
